package fr.babostesting.unit.components.bitmaps
{
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.StageQuality;
	import flash.ui.Multitouch;
	import flash.ui.MultitouchInputMode;
	import fr.babos.core.entries.Document;
	import fr.babos.graphic.components.base.StageWrapper;
	import fr.babos.graphic.components.bitmaps.AdvancedBitmap;
	import fr.babos.graphic.tools.BitmapCache;
	import fr.babos.touch.emulator.MouseToTouchEmulator;
	
	/**
	 * @author ZoulouX
	 */
	public class AdvancedBitmapTest extends Document
	{
		[Embed(source="../../../../../../lib/graphics/layout/zapiks-head-logo.png")]
		public static const ZapiksLogoImage:Class;
		public static const __zapiksLogoImageData:BitmapData = (new ZapiksLogoImage as Bitmap).bitmapData;
		
		[Embed(source="../../../../../../lib/graphics/layout/title-bar-back.png")]
		public static const TitleBarImage:Class;
		public static const __titleBarImageData:BitmapData = (new TitleBarImage as Bitmap).bitmapData;
		
		protected var _wrapper		:StageWrapper;
		protected var _advancedBitmap:AdvancedBitmap;
		protected var _repeat:AdvancedBitmap;
		protected var _imageBitmap:AdvancedBitmap;
		
		public function AdvancedBitmapTest ()
		{
			
		}
		
		
		override public function init ():void
		{
			if (Multitouch.supportsTouchEvents)
			{
				Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;
			}
			else
			{
				MouseToTouchEmulator.emulate(stage, true);
			}
			
			stage.quality = StageQuality.LOW;
			
			_wrapper = new StageWrapper(stage);
			
			_repeat = new AdvancedBitmap(__titleBarImageData, AdvancedBitmap.REPEAT_SCALE_MODE, 2);
			_repeat.place(0, 0, 0, 0).into(_wrapper);
			_repeat.bitmapOffset( -20, -20);
			
			_advancedBitmap = new AdvancedBitmap(__zapiksLogoImageData, AdvancedBitmap.AUTO_SIZE_SCALE_MODE, 2);
			_advancedBitmap.center(0, 50).into(_wrapper).offset(NaN, -6);
			
			_imageBitmap = new AdvancedBitmap(null, AdvancedBitmap.INSIDE_SCALE_MODE);
			_imageBitmap.background(0, .5).place(20, 20, NaN, 20).size(NaN, 150).into(_wrapper);
			
			BitmapCache.create(_wrapper).loadIntoBitmap("http://images.frandroid.com/wp-content/uploads/2010/07/air_20080225162906.jpg", _imageBitmap);
		}
	}
}